package com.linkwedo.saas.project;

import java.util.Date;
import java.util.List;
import javax.servlet.http.HttpServletRequest;
import org.apache.struts2.interceptor.ServletRequestAware;

import com.linkwedo.saas.domain.Time;
import com.linkwedo.saas.util.DateUtil;
import com.opensymphony.xwork2.ActionSupport;


public class AddTimeAction extends ActionSupport implements ServletRequestAware{
	private TimeService TimeService;

	private Integer id;
	private String name;
	private Date dueTime;
	private String description;
	private String taskId;
	private javax.servlet.http.HttpServletRequest request;
	public void setServletRequest(HttpServletRequest request) {
		// TODO Auto-generated method stub
		this.request=request;
	}
	
	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}


	public String getDescription() {
		return description;
	}

	public void setDescription(String description) {
		this.description = description;
	}


	public Date getDueTime() {
		return dueTime;
	}

	public void setDueTime(Date dueTime) {
		this.dueTime = dueTime;
	}

	public String getTaskId() {
		return taskId;
	}

	public void setTaskId(String taskId) {
		this.taskId = taskId;
	}


	private List<Time> list;
	public List<Time> getList() {
		return list;
	}

	public void setList(List<Time> list) {
		this.list = list;
	}


	public static long getSerialversionuid() {
		return serialVersionUID;
	}
	private static final long serialVersionUID = 8190003683775267239L;
	public String execute() throws Exception {
		name=request.getParameter("name");
		description=request.getParameter("description");
		dueTime=DateUtil.str2Date(request.getParameter("dueTimeStr"),"yyyy-MM-dd HH:mm:ss");	
		taskId = request.getParameter("taskId");
		Time pro=new Time();
		pro.setName(name);
		pro.setDescription(description);
		pro.setDueTime(dueTime);
		pro.setTaskId(Integer.parseInt(taskId));
		getTimeService().save(pro);
		list=getTimeService().findByTaskID(Integer.parseInt(taskId));
		return "ok";
	}

	public Integer getId() {
		return id;
	}

	public void setId(Integer id) {
		this.id = id;
	}

	public TimeService getTimeService() {
		return TimeService;
	}

	public void setTimeService(TimeService TimeService) {
		this.TimeService = TimeService;
	}
	
	}
